package org.dentalcard.ui.security;

import org.dentalcard.ui.api.DecInternalFrame;
import org.dentalcard.ui.api.tools.ComponentTableEditor;
import org.dentalcard.ui.api.tools.ComponentTableRenderer;
import org.dentalcard.ui.security.tools.UserTableModel;

import javax.swing.*;
import javax.swing.table.TableCellRenderer;
import java.awt.*;

/**
 * @user: Vladimir Chernishov
 * @date: 20.12.11
 * @time: 23:24
 */
public class UserManagementScr extends DecInternalFrame {
    
    private final JPanel main;
    private UserTableModel userTableModel;
    private JTable userTable;
    
    public UserManagementScr() {
        super("User Management");
        main = new JPanel(new GridBagLayout());
        this.getContentPane().add(main);
        init();
    }

    private void init() {
        userTableModel = new UserTableModel();
        userTable = new JTable(userTableModel);
        userTable.getColumnModel().getColumn(3).setCellRenderer(new ComponentTableRenderer());
        userTable.getColumnModel().getColumn(3).setCellEditor(new ComponentTableEditor());

        userTable.setRowHeight(40);
        userTable.getColumnModel().getColumn(3).setMinWidth(350);
        userTable.getColumnModel().getColumn(3).setMaxWidth(350);

        int rowN = 0;

        main.add(userTable.getTableHeader(), new GridBagConstraints(0, rowN++, 1 ,1, 1, 0, GridBagConstraints.FIRST_LINE_START,
                GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));

        main.add(userTable, new GridBagConstraints(0, rowN++, 1 ,1, 1, 0, GridBagConstraints.FIRST_LINE_START,
                GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));

        main.add(new JLabel("Test"), new GridBagConstraints(0, rowN++, 1 ,1, 1, 1, GridBagConstraints.FIRST_LINE_START,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }


}
